import { getLessonCheckList, updateLessonCheck, clockStudentList } from  '../../../service/api';
import { message } from 'antd';
export default {
  namespace: 'checkLessonManage3',
  state: {
    lessonChecks: {
      list: [],
      total: 0,
    },
    updateLessonResponse: null,
    clockStudentList: [],
  },

  effects: {
    *getLessonCheckList({ payload }, { call, put }) {
      const response = yield call(getLessonCheckList, payload);
      yield put({
        type: 'r_lessonCheckList',
        payload: response,
      });
    },
    *updateLessonCheck({ payload }, { call, put }) {
      const response = yield call(updateLessonCheck, payload);
      yield put({
        type: 'r_updateLessonCheck',
        payload: response,
      });
    },
    *getClockStudentList({ payload }, { call, put }) {
      const response = yield call(clockStudentList, payload);
      yield put({
        type: 'r_clockStudentList',
        payload: response,
      });
    },
  },

  reducers: {
    r_lessonCheckList(state, action) {
      return {
        ...state,
        lessonChecks: action.payload.data,
      };
    },
    r_updateLessonCheck(state, action) {
      return {
        ...state,
        updateLessonResponse: action.payload,
      };
    },
    r_clockStudentList(state, action) {
      return {
        ...state,
        clockStudentList: action.payload.data,
      };
    },
  },
};
